import { IPSDEFormGroupPanel } from './ipsdeform-group-panel';
import { PSDEFormBaseGroupPanelImpl } from './psdeform-base-group-panel-impl';
import { IPSUIActionGroup } from '../../view/ipsuiaction-group';

export class PSDEFormGroupPanelImpl extends PSDEFormBaseGroupPanelImpl implements IPSDEFormGroupPanel {
  get actionGroupExtractMode(): 'ITEM' | 'ITEMS' {
    return this.M.actionGroupExtractMode;
  }

  get buildInActions(): number {
    return this.M.buildInActions != null ? this.M.buildInActions : 0;
  }

  protected psuiactiongroup: IPSUIActionGroup | null = null;

  getPSUIActionGroup(): IPSUIActionGroup | null {
    if (this.psuiactiongroup != null) return this.psuiactiongroup;
    const value = this.M.getPSUIActionGroup;
    if (value == null) {
      return null;
    }
    this.psuiactiongroup = this.getPSModel4('view.IPSUIActionGroup', value, 'getPSUIActionGroup') as IPSUIActionGroup;
    return this.psuiactiongroup;
  }

  get psUIActionGroup(): IPSUIActionGroup | null {
    return this.getPSUIActionGroup();
  }

  getPSUIActionGroupMust(): IPSUIActionGroup {
    const value = this.getPSUIActionGroup();
    if (value == null) {
      throw new Error('未指定界面行为组对象');
    }
    return value;
  }

  get titleBarCloseMode(): 0 | 1 | 2 {
    return this.M.titleBarCloseMode != null ? this.M.titleBarCloseMode : 0;
  }

  get infoGroupMode(): boolean {
    return this.M.infoGroupMode;
  }

  get cls(): string {
    return 'PSDEFormGroupPanelImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.form.IPSDEFormGroupPanel') return true;
    return super.instanceof(cls);
  }
}
